/**
 * 
 */
package org.swing.table.filter.util;

import javax.swing.RowFilter;
import javax.swing.table.TableModel;

import org.swing.table.filter.InlineFilterHeader;
import org.swing.table.imp.InlineFilter;

/**
 * @author lqnhu
 *
 */
public class InlineFilterRowFilter extends RowFilter<TableModel, Integer> {
	private final InlineFilterHeader header;

	public InlineFilterRowFilter(InlineFilterHeader header) {
		this.header = header;
	}

	@Override
	public boolean include(
			javax.swing.RowFilter.Entry<? extends TableModel, ? extends Integer> rowEntry) {
		for (java.util.Map.Entry<Integer, InlineFilter> filterEntry : this.header
				.getFilterMap().entrySet()) {
			Object value = rowEntry.getValue(filterEntry.getKey());
			if (!filterEntry.getValue().filter(value)) {
				return false;
			}
		}
		return true;
	}
}
